package com.wgc.vip.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wgc.vip.domain.Recharge;
import com.wgc.vip.domain.Recharge;
import com.wgc.vip.service.RechargeService;
import com.wgc.vip.mapper.RechargeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 15776
 * @description 针对表【recharge】的数据库操作Service实现
 * @createDate 2024-07-29 22:59:01
 */
@Service
public class RechargeServiceImpl extends ServiceImpl<RechargeMapper, Recharge>
        implements RechargeService {
    @Autowired
    private RechargeMapper rechargeMapper;

    @Override
    public List<Recharge> getAll() {
        LambdaQueryWrapper<Recharge> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Recharge::getIsDelete, 0);
        return rechargeMapper.selectList(queryWrapper);
    }

    @Override
    public Page<Recharge> pageAll(Integer page, Integer size) {
        Page<Recharge> page1 = new Page<>(page, size);
        return this.page(page1, null);
    }

    @Override
    public Page<Recharge> pageList(Recharge e, Integer page, Integer size) {
        Page<Recharge> page1 = new Page<>(page, size);
        return this.page(page1, lqw(e));

    }

    @Override
    public List<Recharge> selectList(Recharge Recharge) {
        return rechargeMapper.selectList(lqw(Recharge));
    }

    public LambdaQueryWrapper<Recharge> lqw(Recharge recharge) {
        LambdaQueryWrapper<Recharge> lqw = new LambdaQueryWrapper<>();
        if (recharge.getId() != null) {
            lqw.eq(Recharge::getId, recharge.getId());
        }
        if (recharge.getVipName() != null) {
            lqw.eq(Recharge::getVipName, recharge.getVipName());
        }
        if (recharge.getRechargeTime() != null) {
            lqw.eq(Recharge::getRechargeTime, recharge.getRechargeTime());
        }
        if (recharge.getPaymentTime() != null) {
            lqw.eq(Recharge::getPaymentTime, recharge.getPaymentTime());
        }
       if (recharge.getOrderNumber() != null) {
            lqw.eq(Recharge::getOrderNumber, recharge.getOrderNumber());
        }
        return lqw;
    }
}




